import { useForm } from "../context/metadata-context";
import eventBus from "../eventBus";
import { isMouseInDomRect } from "../utils";

//打印删去区域连接
export default function (triggerRectFunc = () => {}, effectRectFunc = () => {}, options) {

  const {mode}= useForm();
  if(mode!=="Print"){
    return {}
  }
  function onMouseEnter() {
    eventBus.publish("drawLayer", effectRectFunc(),options);
  }

  function onMouseLeave(event) {
    if (!isMouseInDomRect(event, triggerRectFunc())) {
      eventBus.publish("clearLayer");
    }
  }

  function onMouseOver(event) {
    eventBus.publish("drawLayer", effectRectFunc(),options);
  }

  return { onMouseEnter, onMouseLeave, onMouseOver };
}
